<template>
  <div class="asset-detail-content">
    <RadioGroup v-model="componentName" type="button">
      <Radio label="part">部件</Radio>
<!--      <Radio label="vulnerability">漏洞</Radio>-->
      <Radio label="vulnerability">测试漏洞</Radio>
      <Radio label="bug">测试缺陷</Radio>
      <Radio label="test">测试活动</Radio>
      <Radio label="system">业务系统</Radio>
      <Radio label="dependence">依赖关系</Radio>
      <Radio label="versions">版本信息</Radio>
    </RadioGroup>
    <div class="asset-detail-content-components">
      <part-manage v-if="componentName === 'part'" :productId="productId" ref="partManage"></part-manage>
<!--      <leak-manage-do v-if="componentName === 'vulnerability'"></leak-manage-do>-->
      <leakManageDo v-if="componentName === 'vulnerability'" :productId="productId" ref="vulnerability"/>
      <bugManage v-if="componentName === 'bug'" :productId="productId"  ref="bug" />
      <test-activity v-if="componentName === 'test'" :productId="productId" :productInfo="productInfo"></test-activity>
      <system v-if="componentName === 'system'" :productId="productId" :productInfo="productInfo"></system>
      <versions v-if="componentName === 'versions'" :productId="productId" :productInfo="productInfo" ref="versions"
            @update-success="updateSuccess" @delete-success="updateSuccess"></versions>
      <dependence-page 
          v-if="componentName === 'dependence'"
          :productId="productId"></dependence-page>
    </div>
  </div>
</template>

<script>
import PartManage from './part-manage'
import TestActivity from './test-activity'
import leakManageDo from './leakManageDo'
import DependencePage from './dependence-page.vue';
import system from './system'
import versions from './versions'
import bugManage from "./bugManage.vue";
import PotentialVulnerability from "./potential-vulnerability.vue";
import LeakManageDo from "./leakManageDo.vue";

export default {
  name: 'AssetDetailContent',
  components: {
    LeakManageDo,
    PotentialVulnerability, bugManage,
    PartManage,
    // leakManageDo,
    TestActivity,
    system,
    versions,
    DependencePage
  },
  props: {
    productId: {
      type: String,
      default: ''
    },
    productInfo:{
      type:Object,
      default: ()=>{}
    },
    refresh: {
      Type: Number,
      default: 0
    }
  },
  data() {
    return {
      componentName: 'part'
    }
  },
  watch: {
    componentName(name) {
      this.$nextTick(()=>{
        if(this.$refs[name]&&this.$refs[name].init&&typeof this.$refs[name].init=='function'){
          // //为从被测对象跳转到测试环境特别处理
          this.$refs[name].init({});
        }
      })
    },
      refresh() {
          this.$refs.versions && this.$refs.versions.allowDelete()
      }
  },
  methods: {
    init() {
      this.componentName = 'part'
      this.$nextTick(() => {
        this.$refs.partManage.getNewData()
      })
    },
    updateSuccess() {
        this.$emit('update-versions-success')
    },
    deleteSuccess() {
        this.$emit('delete-versions-success')
    }
  }
}
</script>

<style scoped>
.asset-detail-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;

}
.asset-detail-content .asset-detail-content-components {
  margin-top: 20px;
  flex: 1;
  height: 0;
}
</style>
